package com.example.common;

import com.github.pagehelper.Page;

import java.io.Serializable;
import java.util.*;

/**
 * ResultBean
 */
public class ResultBean implements Serializable {
    private static final long serialVersionUID = 1L;

    // 响应码 0代表
    private String code = "0"; // code

    // 响应码 0代表2
    private String msg = ""; //1 msg
    private long count; // 总数
    private List data; // data
    private Object object; // data

    public ResultBean() {
    }

    public ResultBean(List data) {
        if (data instanceof Page) {
            Page page = (Page) data;
            count = page.getTotal();
        } else {
            count = data.size();
        }
        this.data = data;
    }

    public ResultBean(List data, long count) {
        this.data = data;
        this.count = count;
    }

    public ResultBean(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResultBean(String code, Object object) {
        this.code = code;
        this.object = object;
    }

    public ResultBean(String code, String msg, List data) {
        this.code = code;
        this.msg = msg;
        if (data instanceof Page) {
            Page page = (Page) data;
            count = page.getTotal();
        } else {
            count = data.size();
        }
        this.data = data;
    }

    public ResultBean(String code, String msg, long count, List data) {
        this.code = code;
        this.msg = msg;
        if (data instanceof Page) {
            Page page = (Page) data;
            this.count = page.getTotal();
        } else {
            this.count = data.size();
        }
        this.data = data;
    }

    public static void main(String[] args) {
        HashMap map = new HashMap();
        TreeMap map2 = new TreeMap();
        map.put("a", "1");
        map.put("b", "2");
        ArrayList<String> list = new ArrayList();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        Iterator it = list.iterator();
        while (it.hasNext()) {
            String a = (String) it.next();
            System.out.println(it.next());
        }
        System.out.println(map.values());
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public List getData() {
        return data;
    }

    public void setData(List data) {
        this.data = data;
    }

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }
}